home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 January: Mac OS SDK / Dev.CD Jan 00 SDK1.toast / Development Kits / Mac OS / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / Resources.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  12.6 KB  |  428 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        Resources.h
  3.  
  4.      Contains:    Resource Manager Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8.1
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __RESOURCES__
  19. #define __RESOURCES__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53.  
  54.  
  55. enum {
  56.     resSysHeap                    = 64,                            /*System or application heap?*/
  57.     resPurgeable                = 32,                            /*Purgeable resource?*/
  58.     resLocked                    = 16,                            /*Load it in locked?*/
  59.     resProtected                = 8,                            /*Protected?*/
  60.     resPreload                    = 4,                            /*Load in on OpenResFile?*/
  61.     resChanged                    = 2,                            /*Resource changed?*/
  62.     mapReadOnly                    = 128,                            /*Resource file read-only*/
  63.     mapCompact                    = 64,                            /*Compact resource file*/
  64.     mapChanged                    = 32                            /*Write map out at update*/
  65. };
  66.  
  67.  
  68. enum {
  69.     resSysRefBit                = 7,                            /*reference to system/local reference*/
  70.     resSysHeapBit                = 6,                            /*In system/in application heap*/
  71.     resPurgeableBit                = 5,                            /*Purgeable/not purgeable*/
  72.     resLockedBit                = 4,                            /*Locked/not locked*/
  73.     resProtectedBit                = 3,                            /*Protected/not protected*/
  74.     resPreloadBit                = 2,                            /*Read in at OpenResource?*/
  75.     resChangedBit                = 1,                            /*Existing resource changed since last update*/
  76.     mapReadOnlyBit                = 7,                            /*is this file read-only?*/
  77.     mapCompactBit                = 6,                            /*Is a compact necessary?*/
  78.     mapChangedBit                = 5                                /*Is it necessary to write map?*/
  79. };
  80.  
  81.  
  82. enum {
  83.     kResFileNotOpened            = -1,                            /*ref num return as error when opening a resource file*/
  84.     kSystemResFile                = 0                                /*this is the default ref num to the system file*/
  85. };
  86.  
  87.  
  88. typedef CALLBACK_API( void , ResErrProcPtr )(OSErr thErr);
  89. /*
  90.     WARNING: ResErrProcPtr uses register based parameters under classic 68k
  91.              and cannot be written in a high-level language without 
  92.              the help of mixed mode or assembly glue.
  93. */
  94. typedef REGISTER_UPP_TYPE(ResErrProcPtr)                         ResErrUPP;
  95. enum { uppResErrProcInfo = 0x00001002 };                         /* register no_return_value Func(2_bytes:D0) */
  96. #define NewResErrProc(userRoutine)                                 (ResErrUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppResErrProcInfo, GetCurrentArchitecture())
  97. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  98.     #pragma parameter CallResErrProc(__A0, __D0)
  99.     void CallResErrProc(ResErrUPP routine, OSErr thErr) = 0x4E90;
  100. #else
  101.     #define CallResErrProc(userRoutine, thErr)                     CALL_ONE_PARAMETER_UPP((userRoutine), uppResErrProcInfo, (thErr))
  102. #endif
  103. #if !TARGET_OS_MAC
  104. /* QuickTime 3.0*/
  105. typedef CALLBACK_API( OSErr , ResourceEndianFilterPtr )(Handle theResource, Boolean currentlyNativeEndian);
  106. #endif  /*  !TARGET_OS_MAC */
  107.  
  108. EXTERN_API( short )
  109. InitResources                    (void)                                                        ONEWORDINLINE(0xA995);
  110.  
  111. EXTERN_API( void )
  112. RsrcZoneInit                    (void)                                                        ONEWORDINLINE(0xA996);
  113.  
  114. EXTERN_API( void )
  115. CloseResFile                    (short                     refNum)                                ONEWORDINLINE(0xA99A);
  116.  
  117. EXTERN_API( OSErr )
  118. ResError                        (void)                                                        ONEWORDINLINE(0xA9AF);
  119.  
  120. EXTERN_API( short )
  121. CurResFile                        (void)                                                        ONEWORDINLINE(0xA994);
  122.  
  123. EXTERN_API( short )
  124. HomeResFile                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A4);
  125.  
  126. EXTERN_API( void )
  127. CreateResFile                    (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA9B1);
  128.  
  129. EXTERN_API( short )
  130. OpenResFile                        (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA997);
  131.  
  132. EXTERN_API( void )
  133. UseResFile                        (short                     refNum)                                ONEWORDINLINE(0xA998);
  134.  
  135. EXTERN_API( short )
  136. CountTypes                        (void)                                                        ONEWORDINLINE(0xA99E);
  137.  
  138. EXTERN_API( short )
  139. Count1Types                        (void)                                                        ONEWORDINLINE(0xA81C);
  140.  
  141. EXTERN_API( void )
  142. GetIndType                        (ResType *                theType,
  143.                                  short                     index)                                ONEWORDINLINE(0xA99F);
  144.  
  145. EXTERN_API( void )
  146. Get1IndType                        (ResType *                theType,
  147.                                  short                     index)                                ONEWORDINLINE(0xA80F);
  148.  
  149. EXTERN_API( void )
  150. SetResLoad                        (Boolean                 load)                                ONEWORDINLINE(0xA99B);
  151.  
  152. EXTERN_API( short )
  153. CountResources                    (ResType                 theType)                            ONEWORDINLINE(0xA99C);
  154.  
  155. EXTERN_API( short )
  156. Count1Resources                    (ResType                 theType)                            ONEWORDINLINE(0xA80D);
  157.  
  158. EXTERN_API( Handle )
  159. GetIndResource                    (ResType                 theType,
  160.                                  short                     index)                                ONEWORDINLINE(0xA99D);
  161.  
  162. EXTERN_API( Handle )
  163. Get1IndResource                    (ResType                 theType,
  164.                                  short                     index)                                ONEWORDINLINE(0xA80E);
  165.  
  166. EXTERN_API( Handle )
  167. GetResource                        (ResType                 theType,
  168.                                  short                     theID)                                ONEWORDINLINE(0xA9A0);
  169.  
  170. EXTERN_API( Handle )
  171. Get1Resource                    (ResType                 theType,
  172.                                  short                     theID)                                ONEWORDINLINE(0xA81F);
  173.  
  174. EXTERN_API( Handle )
  175. GetNamedResource                (ResType                 theType,
  176.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A1);
  177.  
  178. EXTERN_API( Handle )
  179. Get1NamedResource                (ResType                 theType,
  180.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA820);
  181.  
  182. #if TARGET_OS_MAC
  183.     #define MacLoadResource LoadResource
  184. #endif
  185. EXTERN_API( void )
  186. MacLoadResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A2);
  187.  
  188. EXTERN_API( void )
  189. ReleaseResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A3);
  190.  
  191. EXTERN_API( void )
  192. DetachResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA992);
  193.  
  194. EXTERN_API( short )
  195. UniqueID                        (ResType                 theType)                            ONEWORDINLINE(0xA9C1);
  196.  
  197. EXTERN_API( short )
  198. Unique1ID                        (ResType                 theType)                            ONEWORDINLINE(0xA810);
  199.  
  200. EXTERN_API( short )
  201. GetResAttrs                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A6);
  202.  
  203. EXTERN_API( void )
  204. GetResInfo                        (Handle                 theResource,
  205.                                  short *                theID,
  206.                                  ResType *                theType,
  207.                                  Str255                 name)                                ONEWORDINLINE(0xA9A8);
  208.  
  209. EXTERN_API( void )
  210. SetResInfo                        (Handle                 theResource,
  211.                                  short                     theID,
  212.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A9);
  213.  
  214. EXTERN_API( void )
  215. AddResource                        (Handle                 theData,
  216.                                  ResType                 theType,
  217.                                  short                     theID,
  218.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9AB);
  219.  
  220. EXTERN_API( long )
  221. GetResourceSizeOnDisk            (Handle                 theResource)                        ONEWORDINLINE(0xA9A5);
  222.  
  223. EXTERN_API( long )
  224. GetMaxResourceSize                (Handle                 theResource)                        ONEWORDINLINE(0xA821);
  225.  
  226. EXTERN_API( long )
  227. RsrcMapEntry                    (Handle                 theResource)                        ONEWORDINLINE(0xA9C5);
  228.  
  229. EXTERN_API( void )
  230. SetResAttrs                        (Handle                 theResource,
  231.                                  short                     attrs)                                ONEWORDINLINE(0xA9A7);
  232.  
  233. EXTERN_API( void )
  234. ChangedResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AA);
  235.  
  236. EXTERN_API( void )
  237. RemoveResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AD);
  238.  
  239. EXTERN_API( void )
  240. UpdateResFile                    (short                     refNum)                                ONEWORDINLINE(0xA999);
  241.  
  242. EXTERN_API( void )
  243. WriteResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9B0);
  244.  
  245. EXTERN_API( void )
  246. SetResPurge                        (Boolean                 install)                            ONEWORDINLINE(0xA993);
  247.  
  248. EXTERN_API( short )
  249. GetResFileAttrs                    (short                     refNum)                                ONEWORDINLINE(0xA9F6);
  250.  
  251. EXTERN_API( void )
  252. SetResFileAttrs                    (short                     refNum,
  253.                                  short                     attrs)                                ONEWORDINLINE(0xA9F7);
  254.  
  255. EXTERN_API( short )
  256. OpenRFPerm                        (ConstStr255Param         fileName,
  257.                                  short                     vRefNum,
  258.                                  SInt8                     permission)                            ONEWORDINLINE(0xA9C4);
  259.  
  260. EXTERN_API( Handle )
  261. RGetResource                    (ResType                 theType,
  262.                                  short                     theID)                                ONEWORDINLINE(0xA80C);
  263.  
  264. /*
  265.     Note:     The HOpenResFile trap was not implemented until System 7.  If you want to call HOpenResFile
  266.             while running on System 6 machines, then define USE_HOPENRESFILE_GLUE and link with
  267.             Interface.o which contains glue to implement HOpenResFile on pre-System 7 machines.
  268. */
  269. #ifdef USE_HOPENRESFILE_GLUE
  270. EXTERN_API( short )
  271. HOpenResFile                    (short                     vRefNum,
  272.                                  long                     dirID,
  273.                                  ConstStr255Param         fileName,
  274.                                  SInt8                     permission);
  275.  
  276. #else
  277. EXTERN_API( short )
  278. HOpenResFile                    (short                     vRefNum,
  279.                                  long                     dirID,
  280.                                  ConstStr255Param         fileName,
  281.                                  SInt8                     permission)                            ONEWORDINLINE(0xA81A);
  282.  
  283. #endif  /*  defined(USE_HOPENRESFILE_GLUE)  */
  284.  
  285. /*
  286.     Note:     The HCreateResFile trap was not implemented until System 7.  If you want to call HCreateResFile
  287.             while running on System 6 machines, then define USE_HCREATERESFILE_GLUE and link with
  288.             Interface.o which contains glue to implement HCreateResFile on pre-System 7 machines.
  289. */
  290. #ifdef USE_HCREATERESFILE_GLUE
  291. EXTERN_API( void )
  292. HCreateResFile                    (short                     vRefNum,
  293.                                  long                     dirID,
  294.                                  ConstStr255Param         fileName);
  295.  
  296. #else
  297. EXTERN_API( void )
  298. HCreateResFile                    (short                     vRefNum,
  299.                                  long                     dirID,
  300.                                  ConstStr255Param         fileName)                            ONEWORDINLINE(0xA81B);
  301.  
  302. #endif  /*  defined(USE_HCREATERESFILE_GLUE)  */
  303.  
  304. EXTERN_API( short )
  305. FSpOpenResFile                    (const FSSpec *            spec,
  306.                                  SignedByte             permission)                            TWOWORDINLINE(0x700D, 0xAA52);
  307.  
  308. EXTERN_API( void )
  309. FSpCreateResFile                (const FSSpec *            spec,
  310.                                  OSType                 creator,
  311.                                  OSType                 fileType,
  312.                                  ScriptCode             scriptTag)                            TWOWORDINLINE(0x700E, 0xAA52);
  313.  
  314. EXTERN_API( void )
  315. ReadPartialResource                (Handle                 theResource,
  316.                                  long                     offset,
  317.                                  void *                    buffer,
  318.                                  long                     count)                                TWOWORDINLINE(0x7001, 0xA822);
  319.  
  320. EXTERN_API( void )
  321. WritePartialResource            (Handle                 theResource,
  322.                                  long                     offset,
  323.                                  const void *            buffer,
  324.                                  long                     count)                                TWOWORDINLINE(0x7002, 0xA822);
  325.  
  326. EXTERN_API( void )
  327. SetResourceSize                    (Handle                 theResource,
  328.                                  long                     newSize)                            TWOWORDINLINE(0x7003, 0xA822);
  329.  
  330. EXTERN_API( Handle )
  331. GetNextFOND                        (Handle                 fondHandle)                            TWOWORDINLINE(0x700A, 0xA822);
  332.  
  333.  
  334. #if !TARGET_OS_MAC
  335. /* QuickTime 3.0*/
  336. EXTERN_API_C( OSErr )
  337. RegisterResourceEndianFilter    (ResType                 theType,
  338.                                  ResourceEndianFilterPtr  theFilterProc);
  339.  
  340. #endif  /*  !TARGET_OS_MAC */
  341.  
  342. /* Use TempInsertROMMap to force the ROM resource map to be
  343.    inserted into the chain in front of the system. Note that
  344.    this call is only temporary - the modified resource chain
  345.    is only used for the next call to the resource manager.
  346.    See IM IV 19 for more information. 
  347. */
  348. EXTERN_API( void )
  349. TempInsertROMMap                (Boolean                 tempResLoad)                        FIVEWORDINLINE(0x70FF, 0x4A1F, 0x56C0, 0x31C0, 0x0B9E);
  350.  
  351.  
  352. #if CGLUESUPPORTED
  353. EXTERN_API_C( Handle )
  354. getnamedresource                (ResType                 theType,
  355.                                  const char *            name);
  356.  
  357. EXTERN_API_C( Handle )
  358. get1namedresource                (ResType                 theType,
  359.                                  const char *            name);
  360.  
  361. EXTERN_API_C( short )
  362. openrfperm                        (const char *            fileName,
  363.                                  short                     vRefNum,
  364.                                  char                     permission);
  365.  
  366. EXTERN_API_C( short )
  367. openresfile                        (const char *            fileName);
  368.  
  369. EXTERN_API_C( void )
  370. createresfile                    (const char *            fileName);
  371.  
  372. EXTERN_API_C( void )
  373. getresinfo                        (Handle                 theResource,
  374.                                  short *                theID,
  375.                                  ResType *                theType,
  376.                                  char *                    name);
  377.  
  378. EXTERN_API_C( void )
  379. setresinfo                        (Handle                 theResource,
  380.                                  short                     theID,
  381.                                  const char *            name);
  382.  
  383. EXTERN_API_C( void )
  384. addresource                        (Handle                 theResource,
  385.                                  ResType                 theType,
  386.                                  short                     theID,
  387.                                  const char *            name);
  388.  
  389. #endif  /* CGLUESUPPORTED */
  390.  
  391. #if OLDROUTINENAMES
  392. #define SizeResource(theResource) GetResourceSizeOnDisk(theResource)
  393. #define MaxSizeRsrc(theResource) GetMaxResourceSize(theResource)
  394. #define RmveResource(theResource) RemoveResource(theResource)
  395.  
  396. #endif  /* OLDROUTINENAMES */
  397.  
  398. /*
  399.     These typedefs were originally created for the Copland Resource Mangager
  400. */
  401. typedef short                             ResFileRefNum;
  402. typedef short                             ResID;
  403. typedef short                             ResAttributes;
  404. typedef short                             ResFileAttributes;
  405.  
  406.  
  407.  
  408. #if PRAGMA_STRUCT_ALIGN
  409.     #pragma options align=reset
  410. #elif PRAGMA_STRUCT_PACKPUSH
  411.     #pragma pack(pop)
  412. #elif PRAGMA_STRUCT_PACK
  413.     #pragma pack()
  414. #endif
  415.  
  416. #ifdef PRAGMA_IMPORT_OFF
  417. #pragma import off
  418. #elif PRAGMA_IMPORT
  419. #pragma import reset
  420. #endif
  421.  
  422. #ifdef __cplusplus
  423. }
  424. #endif
  425.  
  426. #endif /* __RESOURCES__ */
  427.  
  428.